home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha 2008 January / Cybermycha 1_2008.iso / Data.cab / _A440A53976824DBEBB2D2486FBDE92AD < prev    next >
Encoding:
Text File  |  2004-04-29  |  1.1 KB  |  64 lines

  1.  
  2. regc(0, "COMBINED_XFORM")
  3. regc(4, "MODEL_XFORM")
  4.  
  5. regc(12, "FOG_PARAMS")
  6.  
  7. regc(14, "CAMERA_POS_MS")
  8.  
  9. vshader("
  10.  
  11. #define point        v0
  12. #define normal        v1
  13. #define tangent        v2
  14. #define tcoord        v3
  15.  
  16. #define fogp    c12
  17. #define lpos    c13
  18. #define cpos    c14
  19.  
  20. #include    <fog.inc>
  21.  
  22.     vs_1_1
  23.  
  24.     dcl_position    point
  25.     dcl_normal        normal
  26.     dcl_tangent        tangent
  27.     dcl_texcoord    tcoord
  28.  
  29.     ; output position
  30.     m4x4    oPos, point, c0
  31.  
  32.     ; output texcoords
  33.     mov    oT0, tcoord           // color
  34.  
  35.     ; calc tangent space basis, binormal = cross( normal, tangent )
  36.     mov    r2, tangent
  37.     mul    r3, r2.zxyw, normal.yzxw;
  38.     mad    r3, r2.yzxw, normal.zxyw, -r3
  39.  
  40.     ; output tangent -> world-space xform
  41.     dp3    oT2.x, tangent, c4
  42.     dp3    oT3.x, tangent, c5
  43.     dp3    oT4.x, tangent, c6
  44.  
  45.     dp3    oT2.y, r3, c4
  46.     dp3    oT3.y, r3, c5
  47.     dp3    oT4.y, r3, c6
  48.  
  49.     dp3    oT2.z, normal, c4
  50.     dp3    oT3.z, normal, c5
  51.     dp3    oT4.z, normal, c6
  52.  
  53.     ; E in tangent space
  54.     add    r0, cpos, -point
  55.     dp3    oT1.x, tangent, r0
  56.     dp3    oT1.y, r3, r0
  57.     dp3    oT1.z, normal, r0
  58.  
  59.     ; calc fog
  60.        dp4    r0.x, point, c2
  61.        FOG(r0.x, fogp, r10)
  62. ")
  63.  
  64.